package com.chanyachting.emall.serviceImpl;

import java.util.List;

import com.chanyachting.emall.dao.OrdersDAO;
import com.chanyachting.emall.domain.Memberaccount;
import com.chanyachting.emall.domain.Orders;
import com.chanyachting.emall.service.OrdersService;

public class OrdersServiceImpl implements OrdersService {
	
	private OrdersDAO orderDao;

	public OrdersServiceImpl() {
		
		this.orderDao=new OrdersDAO();
	}

	public boolean createOrders(Orders order) {
		
		this.orderDao.save(order);
		
		return true;
	}

	public List<Orders> getAllOrders() {
		
		return this.orderDao.find("from Orders");
	}

	public Orders getOneOrders(Orders order) {
		
		return (Orders) this.orderDao.load(Orders.class, order.getId());
	}

	public List<Orders> getOrdersByMemberAccount(Memberaccount maccount) {
		
		String args[]={String.valueOf(maccount.getId())};
		
		return this.orderDao.find("from Orders where memberAccountId=?",args);
	}

}
